export function formatTimeDifference(interval) {
    const millisecondsPerMinute = 60 * 1000;
    const millisecondsPerHour = 60 * millisecondsPerMinute;
    const millisecondsPerDay = 24 * millisecondsPerHour;
    const millisecondsPerMonth = 30 * millisecondsPerDay;

    if (interval < millisecondsPerMinute) {
        return Math.round(interval / 1000) + " 秒";
    } else if (interval < millisecondsPerHour) {
        return Math.round(interval / millisecondsPerMinute) + " 分钟";
    } else if (interval < millisecondsPerDay) {
        return Math.round(interval / millisecondsPerHour) + " 小时";
    } else if (interval < millisecondsPerMonth) {
        return Math.round(interval / millisecondsPerDay) + " 天";
    } else if (interval < 3 * millisecondsPerMonth) {
        return Math.round(interval / millisecondsPerMonth) + " 个月";
    } else {
        return null;
    }
}


export function gotoHome(){
	uni.showModal({
		title:'提示',
		cinten:'页面有误将返回首页',
		showCancel:false,
		success:(res)=>{
			if(res.confirm){
				uni.reLaunch({
					url:'/pages/index/index'
				})
			}
		}
	})
}

